package com.example.loc_test13;

import com.example.loc_test13.Bean.Bean;
import com.example.loc_test13.Bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.AbstractApplicationEventMulticaster;
import org.springframework.stereotype.Component;

@SpringBootApplication
public class LocTest13Application {
    public static void main(String[] args) {
        ApplicationContext context=SpringApplication.run(LocTest13Application.class, args);
//        BookDao contextBean = context.getBean(BookDao.class);
//        System.out.println(contextBean);
//        contextBean.init("123456789");
//        //注意getBeean的方法取方法名称需要将首字母转小写
//        BookDao contextBean1 = (BookDao) context.getBean("bookDao");
//        System.out.println(contextBean1);
//        contextBean1.init("abc");
//
//        BookDao contextBean2 = context.getBean(BookDao.class, "BookDao");
//        System.out.println(contextBean2);
//        contextBean2.init("////");
//
//        //component
//        Components components = context.getBean(Components.class);
//        components.pintTcomponent();
//        System.out.println(components);
//
//        //Service
//        Service service= context.getBean(Service.class);
//        System.out.println(service);
//        service.Service();
//
//        //Respository
//        Repository repository=context.getBean(Repository.class);
//        System.out.println(repository);
//        repository.repository();
//
//        //Configuration
//        Configuration configuration=context.getBean(Configuration.class);
//        System.out.println(configuration);
//        configuration.configuration();

        //Bean
//        User user = context.getBean(User.class);
//        System.out.println(user);

        //使用方法调用
        User user1 =(User) context.getBean("tbean1");
        System.out.println(user1);

        User user2=(User) context.getBean("tbean2");
        System.out.println(user2);
    }

}
